﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.Products;

namespace Ue.Qcdz.Repositories.Products
{
    internal class ProductFactory : IEntityFactory<Product>
    {
        internal class FieldNames : FieldNamesBase
        {
            public const string ProductTitle = "title";
            public const string ProductImageUrl = "imageUrl";
            public const string ProductLink = "link";
            public const string ProductState = "state";
        }
        public Product BuildEntity(IDataReader reader)
        {
            return new ProductProxy(
                reader.Get<string>(FieldNames.ProductTitle),
                reader.Get<string>(FieldNames.ProductImageUrl),
                reader.Get<string>(FieldNames.ProductLink),
                reader.Get<EntityState>(FieldNames.ProductState),
                reader.Get<Guid>(FieldNames.EntityKey)
                );
        }
    }
}
